repo.or.cz
/
andmenj-acm.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Namespacing everything to /UVa.
[andmenj-acm.git]
/
UVa
/
11505 - Logo
/
11505.cc
blob
82a88cb275e7fd08391f5efc2ab2e10535328f73
1
#include <iostream>
2
#include<math.h>
3
#include<stdio.h>
4
#include<assert.h>
5
#include<string>
6
using namespace
std
;
7
const double
pi
=
acos
(-
1
);
8
inline
double
toRad
(
const double
anl
){
9
return
anl
*
pi
/
180.0
;
10
}
11
int
main
(){
12
int
cases
;
13
cin
>>
cases
;
14
for
(
int
n
;
cases
-- &&
cin
>>
n
;){
15
double
t
,
x
=
0
,
y
=
0
,
teta
=
0
;
16
for
(
string ins
;
n
-- &&
cin
>>
ins
>>
t
;){
17
if
(
ins
==
"fd"
){
18
x
+=
t
*
cos
(
teta
);
19
y
+=
t
*
sin
(
teta
);
20
}
else if
(
ins
==
"bk"
){
21
x
-=
t
*
cos
(
teta
);
22
y
-=
t
*
sin
(
teta
);
23
}
else if
(
ins
==
"lt"
){
24
teta
+=
toRad
(
t
);
25
}
else if
(
ins
==
"rt"
){
26
teta
-=
toRad
(
t
);
27
}
else
{
28
assert
(
false
);
29
}
30
}
31
printf
(
"%.0lf
\n
"
,
sqrt
(
x
*
x
+
y
*
y
));
32
}
33
return
0
;
34
}